﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace Neo4Net.GraphDb
{
    [TestFixture]
    class DirectionTest
    {
        [Test]
        public void DirectionsCompareCorrectlyForEquality()
        {
            Direction incoming = Direction.Incoming;
            Direction outgoing = Direction.Outgoing;
            Direction both = Direction.Both;

            Assert.That(incoming == Direction.Incoming);
            Assert.That(outgoing == Direction.Outgoing);
            Assert.That(both == Direction.Both);
            Assert.That(incoming != Direction.Outgoing);
            Assert.That(incoming != Direction.Both);
            Assert.That(outgoing != Direction.Incoming);
            Assert.That(outgoing != Direction.Both);
            Assert.That(both != Direction.Incoming);
            Assert.That(both != Direction.Outgoing);
        }

        [Test]
        public void IncomingDirectionHasCorrectName()
        {
            TestDirectionName(Direction.Incoming, "Incoming");
        }

        [Test]
        public void OutgoingDirectionHasCorrectName()
        {
            TestDirectionName(Direction.Outgoing, "Outgoing");
        }

        [Test]
        public void BothDirectionHasCorrectName()
        {
            TestDirectionName(Direction.Both, "Both");
        }

        private void TestDirectionName(Direction direction, string expectedName)
        {
            string actualName = direction.ToString();

            Assert.That(actualName, Is.EqualTo(expectedName));
        }

        [Test]
        public void ReverseOfIncomingIsOutgoing()
        {
            TestDirectionReverse(Direction.Incoming, Direction.Outgoing);
        }

        [Test]
        public void ReverseOfOutgoingIsIncoming()
        {
            TestDirectionReverse(Direction.Outgoing, Direction.Incoming);
        }

        [Test]
        public void ReverseOfBothIsBoth()
        {
            TestDirectionReverse(Direction.Both, Direction.Both);
        }

        private void TestDirectionReverse(Direction direction, Direction expectedReverse)
        {
            Direction actualReverse = direction.Reverse();

            Assert.That(actualReverse, Is.EqualTo(expectedReverse));
        }
    }
}
